package com.xianggu.designMode.combination.demo04;

import com.xianggu.designMode.combination.demo04.impl.MultipExpression;
import com.xianggu.designMode.combination.demo04.impl.NumberExpression;
import com.xianggu.designMode.combination.demo04.impl.SubtractExpression;

/**
 * @author chengjy
 * @date 2025/3/20
 */
public class ExpressionDemo {
    public static void main(String[] args) {
        ExpressionParser expressionParser = new ExpressionParser("1+2*3-4/2");
//        List<String> suffix = expressionParser.toSuffix();
//        System.out.println(suffix);
        System.out.println(expressionParser.parse().getValue());
        System.out.println("正确答案: " + (1+2*3-4/2));

        // 计算器功能

        // 1 + 2 * 3 - 4
        Expression add1 = new AddExpression(
                new NumberExpression(1),
                new NumberExpression(2)
        );
        Expression sub2 = new SubtractExpression(
                new NumberExpression(3),
                new NumberExpression(5)
        );

        Expression sub = new MultipExpression(
                add1,
                sub2
        );

        System.out.println(" 1 + 2 * 3 - 4 = " +sub.getValue());
    }
}
